package com.snail.service.impl;

import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.snail.mapper.SysUserMapper;
import com.snail.model.pojo.user.SysUser;
import com.snail.model.vo.user.ThirdPartyUserInfoVO;
import com.snail.service.SysUserService;
import org.springframework.stereotype.Service;

/**

 * @Date 2025/8/18 19:57
 * @Author yangming
 * @Description service实现类
 **/
@Service
@DS("learn-system")
public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> implements SysUserService {

    @Override
    public ThirdPartyUserInfoVO getUsernameById(Long userId) {
        // 参数校验
        if (userId == null || userId <= 0) {
            return null;
        }
        SysUser sysUser= baseMapper.selectUsernameById(userId);
        ThirdPartyUserInfoVO thirdPartyUserInfoVO=new ThirdPartyUserInfoVO();
        if(sysUser==null){
            SysUser sysUsers=new SysUser();
            sysUsers.setNickname("用户不存在");
            sysUsers.setFilePath("1");
            thirdPartyUserInfoVO.setNickname(sysUsers.getNickname());
            thirdPartyUserInfoVO.setAvatar(sysUsers.getFilePath());
        }else if(sysUser!=null){
            thirdPartyUserInfoVO.setNickname(sysUser.getNickname());
            thirdPartyUserInfoVO.setAvatar(sysUser.getFilePath());
        }
        return thirdPartyUserInfoVO;
    }
}
